package cc.angis.xiugallery.provider;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import cc.angis.xiugallery.db.FavouriteImagesDBHelper;
import cc.angis.xiugallery.db.TableConstants;

public class FavouriteImageProvider implements ISourceProvider{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8070527911565519418L;

	private String bucketId;
	
	private Context context;
	
	private List<Long> imageIds;
	
	public FavouriteImageProvider(Context context, String bucketId){
		this.bucketId = bucketId;
		this.context = context;
		imageIds =new ArrayList<Long>();
	}

	@Override
	public Object getItem(int num) {
		return imageIds.get(num);
	}

	@Override
	public int getType() {
		return 0;
	}

	@Override
	public int getSize() {
		return imageIds.size();
	}

	@Override
	public void initSource() {
		FavouriteImagesDBHelper dbHelper  = new FavouriteImagesDBHelper(context, TableConstants.TABLE_FAVOURITE_IMAGES);
		try{
			imageIds = dbHelper.getAllByFavId(Integer.valueOf(bucketId));
		} catch(Exception e){
		} finally {
			dbHelper.closeDB();
		}
		
	}

	@Override
	public String getItemText(int num) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public Object getImageItem(int num) {
		return getItem(num);
	}

}
